package storage
import (
	"github.com/go-redis/redis"
	"github.com/Unknwon/goconfig"
)

func GetRedisClient() *redis.Client {
	var cfg, _= goconfig.LoadConfigFile("conf.ini")
	host , _ := cfg.GetValue("redis", "host")
	port , _ := cfg.GetValue("redis", "port")
	password , _ := cfg.GetValue("redis", "password")
	db , _ := cfg.Int("redis.db", "int")
	client := redis.NewClient(&redis.Options{
		Addr:     host+":"+port,
		Password: password,
		DB: db,
	})
	return client
}


/**
	基础使用案例
	redis:=system.GetRedisClient()
	defer redis.Close()  //随手关闭
	err := redis.Set("key", "value1", 0).Err()
	if err != nil {
		panic(err)
	}
	val, err := redis.Get("key").Result()
	if err != nil {
		panic(err)
	}
 */
